﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Jamhee.Noctiluca.LightWiki.Markup
{
    class Bold : WikiMarkup
    {
        private const string BOLD = @"\*\b(.*?)\b\*";

        protected override string ConvertMarkup(string text, string docFolder, Uri url, MarkupStack stack, Regex regex)
        {
            string html = text;
            MatchCollection matches = regex.Matches(html);
            foreach (Match match in matches)
            {
                if (match.Groups.Count == 2)
                {
                    html = regex.Replace(html, "<b>" + match.Groups[1].Value + "</b>", 1);
                }
            }

            return html;
        }

        protected override string MarkupRegEx
        {
            get { return BOLD; }
        }

        public override bool AddParagraphMarkup
        {
            get { return true; }
        }
    }
}
